<include file="public@header" />
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>

    
</script>
<script type="text/html" id="cert-item-tpl"> 
    <li id="saved-image{id}">
        <input id="cert-{id}" type="hidden" name="cert_urls[]" value="{filepath}">
        <input class="form-control" id="cert-{id}-name" type="text" name="cert_names[]" value="{name}"
            style="width: 200px;" title="图片名称">
        <img id="cert-{id}-preview" src="{url}" style="height:36px;width: 36px;"
            onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#cert-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('AdminIndex/staff')}">员工列表</a></li>
            <li><a href="{:url('AdminIndex/addStaff')}">新增员工</a></li>
			<li class="active"><a >修改员工</a></li>
            
		</ul>
        <form method="post" class="form-horizontal is-ajax-form margin-top-20" action="{:url('AdminIndex/eidtStaffPost')}">
            <div class="form-group">
				<label for="input-user_email" class="col-sm-2 control-label"><span class="form-required">*</span>分类</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="post[category_id]" lay-verify="required" lay-search="" >
                        <!-- <option value="0">请选择 分类</option> -->
                        <foreach name="category" item="ca">
                            <option value="{$ca.id}" <if condition="$staff.category_id eq $ca['id']">selected="selected"</if>>{$ca.name}</option>
                        </foreach>
                      </select>
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('USERNAME')}</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-name" name="post[name]" value="{$staff.name}" required>
				</div>
            </div>
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>头像</label>
				<div class="col-md-6 col-sm-10">
					<ul id="photos" class="pic-list list-unstyled form-inline">
                        <img style="width: 160px;height:160px;" src="{:cmf_get_image_preview_url($staff.avatar)}"/>
                    </ul>
                    <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                               class="btn btn-default-primary btn-sm layui-btn">修改头像</a>
				</div>
            </div>
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>工龄</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-social_work_age" name="post[social_work_age]"  value="{$staff.social_work_age}" required>
				</div>
            </div>
            <div class="form-group">
				<label for="input-user_pass" class="col-sm-2 control-label"><span class="form-required">*</span>性别</label>
				<div class="col-md-6 col-sm-10">
					<input type="radio"  id="input-sex" name="post[sex]" value='0'  {$staff.sex==0?'checked':''}>女
					<input type="radio"  id="input-sex" name="post[sex]" value='1'  {$staff.sex==1?'checked':''}>男
				</div>
			</div>
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>电话</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-tel" name="post[tel]"  value="{$staff.tel}">
				</div>
            </div>
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label">职称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-professional_title" name="post[professional_title]"  value="{$staff.professional_title}" required>
				</div>
            </div>
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label">职业证书</label>
				<div class="col-md-6 col-sm-10">
                    
					<ul id="certificates" class="pic-list list-unstyled form-inline">

                        <notempty name="professional_certificates">
                            <foreach name="professional_certificates" item="vo" key="key">
                                <php>$img_url=cmf_get_image_preview_url($vo);</php>
                                <li id="saved-image{$key}">
                                    <input id="cert-{$key}" type="hidden" name="cert_urls[]"
                                           value="{$vo}">
                                    <input class="form-control" id="cert-{$key}-name" type="text"
                                           name="cert_names[]"
                                           value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                    <img id="cert-{$key}-preview"
                                         src="{:cmf_get_image_preview_url($vo)}"
                                         style="height:36px;width: 36px;"
                                         onclick="parent.imagePreviewDialog(this.src);">
                                    <a href="javascript:uploadOneImage('图片上传','#cert-{$key}');">替换</a>
                                    <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                </li>
                            </foreach>
                        </notempty>
                    </ul>
                    <a href="javascript:uploadMultiImage('图片上传','#certificates','cert-item-tpl');"
                               class="btn btn-default-primary btn-sm layui-btn">上传证书</a>
				</div>
            </div>
            <div class="form-group">
                <label for="input-user_login" class="col-sm-2 control-label">职业证书认证</label>
                
				<div class="col-md-6 col-sm-10">
					<input type="checkbox" name="identification[]" value="1" <php>if($identification!=null && in_array(1,$identification)) echo 'checked'</php>/>医师&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" name="identification[]" value="2"  <php>if($identification!=null &&in_array(2,$identification)) echo 'checked'</php>/>药师&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="checkbox" name="identification[]" value="3"  <php>if($identification!=null && in_array(3,$identification)) echo 'checked'</php>/>健康管理师&nbsp;&nbsp;&nbsp;&nbsp;
                    
				</div>
            </div>
			<div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label">专长</label>
				<div class="col-md-6 col-sm-10">
					<textarea class="form-control" id="input-good_at" name="post[good_at]" > {$staff.good_at}</textarea>
				</div>
            </div>
			
            
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
                    <input class="form-control" type="hidden" id="id" name="post[id]" value="{$staff.id}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				</div>
			</div>
		</form>
	</div>
    <script src="__STATIC__/js/admin.js"></script>
    <script type="text/javascript">
        function getCity(province_id,province_name){
            console.log('getCity'+province_id,province_name)
            $("#province_name").attr("value", province_name)
            $.ajax({
                type: "GET",
                url:"{:url('Index/getCity')}",
                data:{
                    province_id:province_id
                },
                success:function(res){
                    console.log(res)
                    if(res['code']==1){
                        $("#choseCity").html('<option value="" >请选择 市县</option>')
    
                        var html = '',city=res['city'];
                        for(var i in city){
                            html+='<option value="'+city[i]['id']+'" name='+city[i]['name']+'>'+city[i]['name']+'</option>'
                        }
                        
                        $("#choseCity").append(html)
                        $("#choseCountry").html('<option value="" >请选择 地区</option>')
                    }
                }
            })
        }
        function getCountry(city_id,city_name){
            $("#city_name").attr("value", city_name)
    
            $.ajax({
                type: "GET",
                url:"{:url('Index/getCountry')}",
                data:{
                    city_id:city_id
                },
                success:function(res){
                    console.log(res)
                    if(res['code']==1){
                        $("#choseCountry").html('<option value="" >请选择 地区</option>')
    
                        var html = '',county=res['county'];
                        for(var i in county){
                            html+='<option value="'+county[i]['id']+'" name="'+county[i]['name']+'">'+county[i]['name']+'</option>'
                        }
                        $("#choseCountry").append(html)
                    }
                }
            })
        }
    
        function country(country_name){
            $("#country_name").attr("value", country_name)
        }
    </script>    
</body>
</html>